home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / sbin / loadptconf < prev    next >
Text File  |  2006-04-04  |  3KB  |  142 lines

  1. #!/bin/sh
  2. # Version 1.1
  3. # Load some stuff on a usb stick to avoid losing configs and updates when exiting pentoo
  4. # Copyright 2005 Michael Zanetta grimmlin@pentoo.ch
  5.  
  6. BACK_UP="\033[1K\033[0G"
  7. NORMAL="\033[0m"
  8. WARN="\033[33;1m"
  9. BAD="\033[31;1m"
  10. BOLD="\033[1m"
  11. GOOD="\033[32;1m"
  12.  
  13. PENTOODIR="/mnt/usbstick/pentoo/"
  14.  
  15. DOROOT=0
  16. DONESSUS=0
  17. DOETC=0
  18. DOFP=0
  19. DOTREE=0
  20. EXIT=0
  21.  
  22. source /sbin/functions.sh
  23.  
  24. try() {
  25.         local errstr
  26.         local retval=0
  27.  
  28.         if [ -c /dev/null ]; then
  29.                 errstr="$((eval $*) 2>&1 >/dev/null)"
  30.         else
  31.                 errstr="$((eval $*) 2>&1)"
  32.         fi
  33.         retval=$?
  34.         if [ "${retval}" -ne 0 ]
  35.         then
  36.                 splash "critical" &
  37.  
  38.                 echo -e "${ENDCOL}${NORMAL}[${BAD} oops ${NORMAL}]"
  39.                 echo
  40.                 eerror "The \"${1}\" command failed with error:"
  41.                 echo
  42.                 echo "${errstr#*: }"
  43.                 echo
  44.         fi
  45.  
  46.         return ${retval}
  47. }
  48.  
  49. domount() {
  50.     mount -o loop "${PENTOODIR}"$1.img /$1
  51. }
  52.  
  53. parse_opt() {
  54.         case "$1" in
  55.                 *\=*)
  56.                         echo "$1" | cut -f2 -d=
  57.                 ;;
  58.         esac
  59. }
  60.  
  61. CMDLINE="`cat /proc/cmdline`"
  62. # Scan CMDLINE for any specified stick= arguments
  63. for x in ${CMDLINE}
  64. do
  65.         case "${x}" in
  66.                 stick\=*)
  67.                         DEVDIR=`parse_opt "${x}"`
  68.                 ;;
  69.         esac
  70. done
  71.  
  72. if [ -z "${DEVDIR}" ]; then
  73.         DEVDIR="/dev/sda1"
  74. fi
  75.  
  76. dostuff() {
  77.     if [ -e "${PENTOODIR}".pentoorc ]; then
  78.         # Pentoo config file exist, sourcing it and linking the files...
  79.         SOFTWARE=`cat "${PENTOODIR}".pentoorc`
  80.         for x in ${SOFTWARE}
  81.         do
  82.                 case "${x}" in
  83.                         root)
  84.                                 DOROOT=1
  85.                 ;;
  86.                         ExploitTree)
  87.                                 DOTREE=1
  88.                         ;;
  89.                         nessus)
  90.                                 DONESSUS=1
  91.                         ;;
  92.                         etc)
  93.                                 DOETC=1
  94.                         ;;
  95.                         fingerprints)
  96.                                 DOFP=1
  97.                         ;;
  98.                 esac
  99.         done
  100.         if [ "${DOROOT}" -eq '1' ]; then
  101.             ebegin "  Mounting /root from usbstick"
  102.             try domount root
  103.             eend $?
  104.         fi
  105.         if [ "${DOETC}" -eq '1' ]; then
  106.             ebegin "  Mounting /etc from usbstick"
  107.             try domount etc
  108.             eend $?
  109.         fi
  110.                 if [ "${DOTREE}" -eq '1' ]; then
  111.             ebegin "  Linking Exploit Tree to usbstick"
  112.             rm -rf /opt/pentoo/ExploitTree*
  113.             ln -sf "${PENTOODIR}"ExploitTree/ /opt/pentoo/ExploitTree
  114.             ln -sf "${PENTOODIR}"ExploitTree.pl /opt/pentoo/ExploitTree.pl
  115.             eend $?
  116.                 fi
  117.         if [ "${DOFP}" -eq '1' ]; then
  118.             ebegin "  Linking FingerPrints DB to usbstick"
  119.             rm -rf /var/lib/fingerprints
  120.             ln -sf "${PENTOODIR}"fingerprints/ /var/lib/fingerprints
  121.             eend $?
  122.         fi
  123.         if [ "${DONESSUS}" -eq '1' ]; then
  124.             ebegin "  Linking nessus's plugins to usbstick"
  125.             rm -rf /usr/lib/nessus/
  126.             ln -sf "${PENTOODIR}"nessus/ /usr/lib/nessus/
  127.             eend $?
  128.         fi
  129.     else
  130.         umount /mnt/usbstick
  131.     fi
  132. }
  133. if [ -e /mnt/cdrom/pentoo/.pentoorc ];
  134. then
  135.     PENTOODIR="/mnt/cdrom/pentoo/"
  136.     dostuff
  137. else
  138.     if mount "${DEVDIR}" /mnt/usbstick/ &>/dev/null ; then
  139.         dostuff
  140.     fi
  141. fi
  142.